<template>
  <div class="todo-footer" v-show="total">
		<label>
			<!-- <input type="checkbox" :checked="siAll" @click="allchoose"/> -->
			<!-- 设置是否全选 -->
			<input type="checkbox" v-model="isAll"/>
		</label>
		<span>
			<span>已完成{{choose}}</span> / 全部{{total}}
		</span>
		<button class="btn btn-danger" @click="deletedAll">清除已完成任务</button>
	</div>
</template>

<script>
export default {
 name:'MyFloot',
 props:['items','allture','deleteAllChoose'],
 methods:{
    // allchoose(e){
    //   this.allture(e.target.checked)    
	// },
	//删除全部
	deletedAll(){
         this.deleteAllChoose()
	}
 },
 computed:{
	//全部的个数
	total(){
		return this.items.length
	},
	choose(){
		// this.items.reduce((pre,current) =>{
		// return pre + (current.done ? 1 : 0)
		// },0 )
		//算出选的个数
		return this.items.reduce((pre,current) => pre + (current.done ? 1: 0),0)
	},
	isAll:{
		//如果总是相等那就全选
        get(){
           return this.total === this.choose
		},
		//传给app让其设置全选
		set(value){
			this.allture(value)
		}
		
	}
 }
}
</script>

<style scoped>
/*footer*/
	.todo-footer {
		height: 40px;
		line-height: 40px;
		padding-left: 6px;
		margin-top: 5px;
	}

	.todo-footer label {
		display: inline-block;
		margin-right: 20px;
		cursor: pointer;
	}

	.todo-footer label input {
		position: relative;
		top: -1px;
		vertical-align: middle;
		margin-right: 5px;
	}

	.todo-footer button {
		float: right;
		margin-top: 5px;
	}
</style>